package hhpoll.validation;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class PasswordValidator implements Validator {

	@Override
	public boolean supports(Class clazz) {
		return String.class.equals(clazz);
	}

	@Override
	public void validate(Object obj, Errors errors) {
		String password = (String)obj;
		if (password.length() < 8)
			errors.rejectValue("password", "password.too.weak");
	}

}
